home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Sample.bin / NervousTextClass.java < prev    next >
Text File  |  1998-10-28  |  5KB  |  201 lines

  1. /*
  2.     A basic extension of the java.awt.Frame class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. import symantec.itools.multimedia.*;
  8. import symantec.itools.multimedia.NervousText;
  9. public class NervousTextClass extends Frame
  10. {
  11.     public NervousTextClass()
  12.     {
  13.         // This code is automatically generated by Visual Cafe when you add
  14.         // components to the visual environment. It instantiates and initializes
  15.         // the components. To modify the code, only use code syntax that matches
  16.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  17.         // parse your Java file into its visual environment.
  18.         //{{INIT_CONTROLS
  19.         setLayout(null);
  20.         setVisible(false);
  21.         setSize(492,270);
  22.         setBackground(java.awt.Color.cyan);
  23.         nervousText1 = new symantec.itools.multimedia.NervousText();
  24.         try {
  25.             nervousText1.setText("       Nervous Text");
  26.         }
  27.         catch(java.beans.PropertyVetoException e) { }
  28.         nervousText1.setBounds(2,28,487,57);
  29.         add(nervousText1);
  30.         button1 = new java.awt.Button();
  31.         button1.setActionCommand("button");
  32.         button1.setLabel("Change");
  33.         button1.setBounds(256,200,60,40);
  34.         add(button1);
  35.         button2 = new java.awt.Button();
  36.         button2.setActionCommand("button");
  37.         button2.setLabel("Close");
  38.         button2.setBounds(337,200,60,40);
  39.         add(button2);
  40.         button3 = new java.awt.Button();
  41.         button3.setActionCommand("button");
  42.         button3.setLabel("Pause");
  43.         button3.setBounds(175,200,60,40);
  44.         add(button3);
  45.         button4 = new java.awt.Button();
  46.         button4.setActionCommand("button");
  47.         button4.setLabel("Start");
  48.         button4.setBounds(94,200,60,40);
  49.         add(button4);
  50.         setTitle("Untitled");
  51.         //}}
  52.  
  53.         //{{INIT_MENUS
  54.         //}}
  55.  
  56.         //{{REGISTER_LISTENERS
  57.         SymWindow aSymWindow = new SymWindow();
  58.         this.addWindowListener(aSymWindow);
  59.         SymAction lSymAction = new SymAction();
  60.         button1.addActionListener(lSymAction);
  61.         button2.addActionListener(lSymAction);
  62.         button3.addActionListener(lSymAction);
  63.         button4.addActionListener(lSymAction);
  64.         //}}
  65.     }
  66.  
  67.     public NervousTextClass(String title)
  68.     {
  69.         this();
  70.         setTitle(title);
  71.     }
  72.  
  73.     public void addNotify()
  74.     {
  75.         // Record the size of the window prior to calling parents addNotify.
  76.         Dimension d = getSize();
  77.         
  78.         super.addNotify();
  79.  
  80.         if (fComponentsAdjusted)
  81.             return;
  82.  
  83.         // Adjust components according to the insets
  84.         Insets insets = getInsets();
  85.         setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
  86.         Component components[] = getComponents();
  87.         for (int i = 0; i < components.length; i++)
  88.         {
  89.             Point p = components[i].getLocation();
  90.             p.translate(insets.left, insets.top);
  91.             components[i].setLocation(p);
  92.         }
  93.         fComponentsAdjusted = true;
  94.     }
  95.  
  96.  
  97.     
  98.  
  99.     // Used for addNotify check.
  100.     boolean fComponentsAdjusted = false;
  101.  
  102.     //{{DECLARE_CONTROLS
  103.     symantec.itools.multimedia.NervousText nervousText1 = new symantec.itools.multimedia.NervousText();
  104.     java.awt.Button button1 = new java.awt.Button();
  105.     java.awt.Button button2 = new java.awt.Button();
  106.     java.awt.Button button3 = new java.awt.Button();
  107.     java.awt.Button button4 = new java.awt.Button();
  108.     //}}
  109.  
  110.     //{{DECLARE_MENUS
  111.     //}}
  112.  
  113.     class SymWindow extends java.awt.event.WindowAdapter
  114.     {
  115.         public void windowClosing(java.awt.event.WindowEvent event)
  116.         {
  117.             Object object = event.getSource();
  118.             if (object == NervousTextClass.this)
  119.                 Frame1_WindowClosing(event);
  120.         }
  121.     }
  122.     
  123.     void Frame1_WindowClosing(java.awt.event.WindowEvent event)
  124.     {
  125.         //hide();         // hide the Frame
  126.         dispose();
  127.     }
  128.  
  129.     class SymAction implements java.awt.event.ActionListener
  130.     {
  131.         public void actionPerformed(java.awt.event.ActionEvent event)
  132.         {
  133.             Object object = event.getSource();
  134.             if (object == button1)
  135.                 button1_Action(event);
  136.             else if (object == button2)
  137.                 button2_Action(event);
  138.             else if (object == button3)
  139.                 button3_Action(event);
  140.             else if (object == button4)
  141.                 button4_Action(event);
  142.         }
  143.     }
  144.  
  145.     void button1_Action(java.awt.event.ActionEvent event)
  146.     {
  147.         // to do: code goes here.
  148.              
  149.         //{{CONNECTION
  150.         // Set the text for NervousText...
  151.         {
  152.             try {
  153.                 nervousText1.setText("You just Changed the text");
  154.             }
  155.             catch(java.beans.PropertyVetoException e) { }
  156.         }
  157.         //}}
  158.     }
  159.  
  160.     void button2_Action(java.awt.event.ActionEvent event)
  161.     {
  162.         // to do: code goes here.
  163.              
  164.         //{{CONNECTION
  165.         // Hide the Frame
  166.         setVisible(false);
  167.         dispose();
  168.         //}}
  169.     }
  170.  
  171.     void button3_Action(java.awt.event.ActionEvent event)
  172.     {
  173.         // to do: code goes here.
  174.              
  175.         //{{CONNECTION
  176.         // Pause the NervousText
  177.         {
  178.             try {
  179.                 nervousText1.setPaused(true);
  180.             }
  181.             catch(java.beans.PropertyVetoException e) { }
  182.         }
  183.         //}}
  184.     }
  185.  
  186.     void button4_Action(java.awt.event.ActionEvent event)
  187.     {
  188.         // to do: code goes here.
  189.              
  190.         //{{CONNECTION
  191.         // Resume the NervousText
  192.         {
  193.             try {
  194.                 nervousText1.setPaused(false);
  195.             }
  196.             catch(java.beans.PropertyVetoException e) { }
  197.         }
  198.         //}}
  199.     }
  200. }
  201.